package org.jeecg.modules.emissionCoal.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.emissionCoal.entity.EmissionCoal;
import org.jeecg.modules.emissionCoal.mapper.EmissionCoalMapper;
import org.jeecg.modules.emissionCoal.service.IEmissionCoalService;
import org.springframework.stereotype.Service;

/**
 * @Description: 标煤排放方案
 * @Author: jeecg-boot
 * @Date:   2023-06-20
 * @Version: V1.0
 */
@Service
public class EmissionCoalServiceImpl extends ServiceImpl<EmissionCoalMapper, EmissionCoal> implements IEmissionCoalService {
    @Override
    public void updateStatus(EmissionCoal emissionCoal){
        if ("默认方案".equals(emissionCoal.getStatus())){
            EmissionCoal coal = new EmissionCoal();
            coal.setStatus("备用方案");
            baseMapper.update(coal,null);
        }
    }

    @Override
    public EmissionCoal getCoefficient() {
        LambdaQueryWrapper<EmissionCoal> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(EmissionCoal::getStatus, "默认方案");
        return baseMapper.selectOne(queryWrapper);
    }
}
